package Test_0806.demo1;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-08-06
 * Time: 17:05
 */
public class Computer {
     public void  open(){
         System.out.println("开机");
     }
     public void close(){
         System.out.println("关机");
     }
     //使用USB功能
    public void useUSBDevice(USB usb){
         usb.openDevice();
         //使用鼠标功能
        if(usb instanceof Mouse){
            //向下转型
            Mouse mouse=(Mouse)usb;
            mouse.click();
        } else{//使用键盘
            KeyBoard keyBoard=(KeyBoard)usb;
            keyBoard.inPut();
        }
        usb.closeDevice();
    }
}
